package com.cxyxj.pcd.annon;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

@Aspect
@Component
public class TimeAspect {

    private static final String Pattern = "yyyy-MM-dd HH:mm:ss";

    static final String axx = "execution(* com.cxyxj.aopannon.UserController.queryUser(..))";

    @Pointcut(
            "@target(com.cxyxj.pcd.annon.MyAnnon)")
    public void pointcutCommon(){

    }
    @Before(value = "pointcutCommon()")
    public void before(JoinPoint joinPoint){
        LocalDateTime now = LocalDateTime.now();
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern(Pattern);
        String timeStr = now.format(formatter);
        System.out.println("方法执行开始时间：" + timeStr);
    }
}
